package com.guoyu.project.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.google.common.collect.Maps;
import com.guoyu.project.common.pagination.Pagination;
import com.guoyu.project.dao.Project_DynamicDao;
import com.guoyu.project.model.Project_Dynamic;
import com.guoyu.project.model.Project_Manage;

@Service
public class Project_DynamicService {

	@Resource
	private Project_DynamicDao project_DynamicDao;
	
	//添加
    public void saveProject_Dyanmic(Project_Dynamic project_dynamic) {
    	project_DynamicDao.save(project_dynamic);
    }

    //更新
    public void updateProject_Dyanmic(Project_Dynamic project_dynamic) {
    	project_DynamicDao.update(project_dynamic);
    }

    /**
     * 删除
     */
    public void deleteById(int pd_id) {
    	project_DynamicDao.deleteById(pd_id);
    }

    /**
     * 根据id获取信息数据
     */
    public Project_Dynamic queryById(int pd_id) {
        return project_DynamicDao.queryById(pd_id);
    }

    /**
     * 根据条件分页查询信息数据
     *
     * @param offset
     * @param limit
     * @param params
     * @return
     */
    public Pagination<Project_Dynamic> queryAllProject_Dynamic(int offset, int limit, Map<String, Object> params) {
        // 根据条件获取总记录数
        int total = project_DynamicDao.queryPDCount(params);

        // 构建分页对象，参数
        if (null == params) {
            params = Maps.newHashMap();
        }
        params.put(Pagination.OFFSET, offset);
        params.put(Pagination.LIMIT, limit);

        // 分页查询数据
        List<Project_Dynamic> pdList = project_DynamicDao.queryAllProject_Dynamic(params);
        return new Pagination(offset, limit, total, pdList);
    }

    public List<Project_Dynamic> queryAllProject_Dynamic(Map<String, Object> params) {
        return project_DynamicDao.queryAllProject_Dynamic(params);
    }
    public Pagination<Project_Dynamic> queryBypmanageId(int offset, int limit, Map<String, Object> params){
    	
    	int total = project_DynamicDao.queryPDCount(params);

        // 构建分页对象，参数
        if (null == params) {
            params = Maps.newHashMap();
        }
        params.put(Pagination.OFFSET, offset);
        params.put(Pagination.LIMIT, limit);
        List<Project_Dynamic> list = project_DynamicDao.queryBypmanageId(params);
        return new Pagination(offset, limit, total, list);
    }
}